﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
namespace PRO.Common
{
    public class ControlTool
    {
        public string GetSelectedKeysInDataList(DataList dl, string controlName)
        {
            StringBuilder sb = new StringBuilder();
            foreach (DataListItem dli in dl.Items)
            {
                CheckBox chk = dli.FindControl(controlName) as CheckBox;
                if (chk != null && chk.Checked)
                {
                    sb.Append(dl.DataKeys[dli.ItemIndex]);
                    sb.Append(",");
                }

            }
            string str = sb.ToString().Trim(',');
            return str;
        }

        public int IsSeleted(DataList dl,string checkname)
        {
            foreach (DataListItem dli in dl.Items)
            {
                CheckBox chk = dli.FindControl(checkname) as CheckBox;
                if (chk != null && chk.Checked)
                {
                    return 1;
                }

            }
            return 0;
        }
    }
}
